﻿using Gobang.Client.View.CustomControl;
using Gobang.Client.View.FrmPage;
using Sunny.UI;

namespace Gobang.Client.View
{
    public partial class FrmGobangMain : UIForm
    {
        private readonly GobangPage _gobangPage;
        public readonly ChessGameControl _chessGameControl;
        public FrmGobangMain(ChessGameControl chessGameControl)
        {
            InitializeComponent();
            _chessGameControl = chessGameControl;
            _gobangPage = new GobangPage(this);
            _gobangPage.Dock = DockStyle.Fill;
            this.uiPanel2.Controls.Add(_gobangPage);
            _gobangPage.Show();
        }

        private void FrmGobangMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            _gobangPage.Dispose();
            this.Dispose();
        }

        private void sbtnSend_Click(object sender, EventArgs e)
        {
            SendMessage();
        }
        private void SendMessage()
        {
            ChatControl chatControl = new ChatControl();
            chatControl.Content = this.txtMessage.Text;
            this.flpMessage.Controls.Add(chatControl);
            this.txtMessage.Text = string.Empty;
        }
        private void txtMessage_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendMessage();
            }
        }
    }
}
